package com.chhlz.module.base.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.chhlz.module.base.dao.CustomerDao;
import com.chhlz.module.base.model.Customer;
import com.chhlz.module.service.CustomerService;


/**
 * 客户业务实现类
 * @author DCJ
 *
 */
@Service
public class CustomerServiceImpl implements CustomerService {
	@Autowired
	private CustomerDao customerDao;

	@Override
	public int getTotal() {
		return customerDao.countAll();
	}
	@Override
	public boolean isExist(String customerNo) {
		boolean flag = false;
		String hql="from Customer as c where c.CustomerNo="+customerNo;
		if (customerDao.find(hql).size()>0){
			flag = true;
		}
		return flag;
	}
	@Override
	public int save(Customer t) {
		return this.customerDao.save(t);
	}
	@Override
	public void update(Customer t) {
		this.customerDao.update(t);
	}
	@Override
	public void delete(int id) {
		Customer c = this.customerDao.get(id);
		this.customerDao.delete(c);
	}
	@Override
	public List<Customer> findAll(int page, int rows, String sort, String order) {
		return this.customerDao.findAll(page, rows, sort, order);
	}
}
